package com.qf.shiro2302.controller;

import com.qf.shiro2302.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.NotNull;

@RestController
@RequestMapping("/user")
@Validated  // 开启参数校验功能
@Slf4j
public class UserController {

    @Autowired
    UserService userService;

    @PostMapping("/register")
    public String register(@NotNull String username,@NotNull String password) throws Exception {
        log.info("入参为,username={},password={}",username,password);
        userService.register(username,password);

        return "register ok";
    }

}
